/**********************************************************************
 *
 * $RCSfile: EntityTemplateDropDownListener.java,v $  $Revision: 1.1 $  $Date: 2009/06/16 09:13:35 $
 *
 * $Log: EntityTemplateDropDownListener.java,v $
 * Revision 1.1  2009/06/16 09:13:35  @author simplefan
 * *** empty log message ***
 *
 *
 *
 *********************************************************************/
/*
 * Copyright 2008 gxlu, Inc. All rights reserved.
 * File name : EntityTemplateDropDownListener.java
 * Created on : Jun 16, 2009 10:19:24 AM
 * Creator : lethe
 */
package com.simplefan.meta.determine.client.web.listener;

import java.util.List;

import com.bstek.dorado.common.DoradoContext;
import com.bstek.dorado.data.Dataset;
import com.simplefan.meta.determine.client.desktop.service.MetaPlatformServiceFacade;
import com.simplefan.meta.determine.common.po.EntityMgtTemplate;

/**
 * <pre>
 * Description : TODO
 * @author simplefan
 * </pre>
 */
public class EntityTemplateDropDownListener extends MetaPlatformListener {
	@Override
  public void afterLoadData(Dataset dataset) throws Exception {
		super.afterLoadData(dataset);
		MetaPlatformServiceFacade facade = getServiceFacade();
		String name = dataset.parameters().getString("name");
		long entityId = 0;
		if(DoradoContext.getContext().getParameter("entityId")!=null && 
				DoradoContext.getContext().getParameter("entityId").length()>0){
			entityId = Long.parseLong(DoradoContext.getContext().getParameter("entityId"));
			
		}
		if(entityId<=0){
			entityId = dataset.parameters().getLong("entityId");
		}
		List<EntityMgtTemplate> list = facade.getServiceFactory().getMetaPlatformService().findEntityMgtTemplate(entityId, name, null, null);
		dataset.fromDO(list);
	}
}
